<?php
function testaHtml($tit2, $tit3, $msgPag, $codMenu=null,$aOpz=array()) {
	global $objSess, $objDB, $isReloadable, $isPopUp, $sXSNQS ;
	$coloreSfondo = OVF_COLORE_SFONDO;
	$coloreTesto = OVF_COLORE_TESTO;
	if (!isset($aOpz['no-cache']) or $aOpz['no-cache']) {
		header("Cache-Control: no-cache, must-revalidate");
		header("Pragma: no-cache");
		header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
	}
	$nX = hexdec(substr($coloreTesto,0,2))+hexdec(substr($coloreTesto,2,2))+hexdec(substr($coloreTesto,4,2));
	$fontFamily=($nX<512)?"arial":"arialbd";
	if (strpos($_SERVER["PHP_SELF"],"/wfma/")===false) {
		$tit1 = OVF_TITOLO1;
	} else {
		$tit1 = WFM_TITOLO1;
	}
	if (!defined("OVF_SFONDO_PAGINA")) {
		$sBackGround = "background-image:url('".OVF_URL_ROOT."/app/_img/bodybg.jpg');";
	} elseif (substr(OVF_SFONDO_PAGINA,0,1)=='#') {
		$sBackGround = "background-color:".OVF_SFONDO_PAGINA.";";
	} else {
		$sBackGround = "background-image:url('".OVF_SFONDO_PAGINA."');";
	}
   $height = (OVF_DBG_FLAG_DISPLAY=='N')?800:100;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta Name="expires" CONTENT= "Mon, 1 Jan 2000 00:00:00 GMT">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<meta HTTP-EQUIV="content-language" content="it">
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href='<?=OVF_URL_ROOT?>/app/_img/ovf.ico' type="image/x-icon" />
<link rel="stylesheet" href="<?=OVF_URL_ROOT?>/app/_com/css.stilePar.php?cs=<?=$coloreSfondo?>&ct=<?=$coloreTesto?>" type="text/css">
<title><?=$tit1?></title>
<script type="text/javascript">
<?php echo ovfNewsJavascript();?>
</script>
</head>
<body style="font-family:arial;margin:0;<?=$sBackGround?>" onload="scriviNews();">
<table cellpadding='0' cellspacing='0' border='0'
	style='font-family:arial;background-color:#ffffff;width:990px;border:#ffffff 10px solid;' align='center'>
	<tr>
		<td colspan='2'>
			<table border="0" width="100%" cellpadding="0" cellspacing="0" 
				style='background-color:#FFFFFF;color:#000000;'>
			   <tr>
			      <td width='1%' style='padding:2px;'><?php echo getHtmlImgLogo();?></td>
			      <td style='font-size:14pt;' align='left' width='70%'>
			         &nbsp;<b><?=getHtmlImgGen($tit1, 300, 35, 'FFFFFF', '000000', 18)?></b><br/>
			         &nbsp;<?=getHtmlImgGen($tit2, 300, 25, 'FFFFFF', '000000', 14)?>
			      </td>
			      <td width='29%' style='padding:2px;'>
			      	<div class='cmd1' id='newsBox' 
			      		style='padding:0 0 3 0;font-size:8pt;border:black 1px solid;height:65;width:400;cursor:pointer;'
			      		title='<?_t("visualizza tutte le news")?>'
			      		onClick='//apriNews();'>&nbsp;</div>
			      </td>
			   </tr>
			</table>
			<table width='100%' align='center' cellpadding='0' cellspacing='0'>
			   <tr>
			      <td style='border-top:solid 1px #000000;'>
						<table border="0" width="100%" cellpadding="3" cellspacing="0" align='center'>
						   <tr>
						      <td class='cmd1'>
						      
<?	
	if (is_object($objSess)) {
		echo $objSess->nome." (".$objSess->lingua.")";
	} else {
		echo "-- out of session --";
	}
?>
						      </td>
						      <td class='cmd1' align='right'>
<?
	if (isset($isReloadable) and $isReloadable and (!isset($isPopUp) or !$isPopUp)) {
?>
			         &nbsp;&nbsp;&nbsp;
			         <a style='font-size:8pt;' href="<?=OVF_URL_ROOT."/app/_com/cloneSession.php?xsn=".XSN?>" 
			         	target="_blank" class='cmd1'><?=_t("nuova finestra")?></a>
			         &nbsp;&nbsp;&nbsp;
			         <a style='font-size:8pt;' href="<?=OVF_URL_ROOT."/app/_com/logOut.php?xsn=".XSN?>" 
			         	class='cmd1'>log-out</a>
<? 
	} 
									echo "&nbsp;&nbsp;&nbsp;";
			         			echo "<a style='font-size:8pt;' href='".OVF_URL_ROOT."/app/_com/overfly_doc_".$objSess->lingua.".pdf' "
			         			." target='_blank' class='cmd1'>"._t("manuale utente")."</a>";
									?>
						      </td>						      
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr height='<?=$height?>'>
		<td width='150' class='cmd1' valign='top' style='padding:2px;text-align:center;'>
			<?php 
			$contaRigheMenu = 0;
			include OVF_FS_WEB_ROOT."/app/_inc/inc.allMenu.php";
			echo "<br/><img src='".OVF_URL_ROOT."/app/_img/logo20.gif' border='0'/>&nbsp;&nbsp;&nbsp;";
			echo file_get_contents(OVF_FS_WEB_ROOT."/app/_inc/versione.txt");?>
		</td>
		<td width='840' valign='top' style='padding:2px;' >
			<div class='tit1' style='padding:5 0 0 0;text-align:center;margin:0;'>
			<?=getHtmlImgGen($tit3, 800, 20, OVF_COLORE_SFONDO, OVF_COLORE_TESTO, 14)?></div>
<?
	if (isset($aOpz['sottotit'])) {
		echo "<div class='cmd1' style='margin:0;padding:0;'>".$aOpz['sottotit']."</div>\n";
	}
?>
			<div class='err1' align='center'><?php echo $msgPag?>&nbsp;</div>
			<div>
<?
	// la chiusura della td/tr/table e' nella function codaHtml
	if (false) { // mai ! - serve per eliminare la segnalazione di tag non chiuso !!!!!!!!!!!!!!!!!!
?>
			</div>
		</td>
	</tr>
</table>
<?php 
	}
}

function getCodaHtml() {
	global $objSess, $objDB;
	$sHTML = "</div></td></tr>\n";
	$sHTML .= "</table>\n";
	$scnds = '';
	if (isset($objSess->mcrTmStrt)) {
		$sHTML .= "<SCRIPT>\n";
		$scnds = number_format(microtime(true)-$objSess->mcrTmStrt,3,',','.');
		$sHTML .= "   window.status = '$scnds sec.';\n";
		$sHTML .= "</SCRIPT>\n";	
	}
	$sHTML .= "</div>\n";
   if (OVF_DBG_FLAG_DISPLAY=='D') {
      $sHTML .=  "<pre width='132'>\r\n-------- ELAB-INFO durata: $scnds sec. - id_utente: ".$objSess->idUtente." - '".LOGIN."' - DB: ".OVF_DB_NAME."(".OVF_DB_HOST.")\r\n";;
      $fileLog = OVF_FS_LOG_DIR."/lasterror";
      if (file_exists($fileLog)) {
      	$sHTML .= "*** ERRORI ***\r\n".file_get_contents($fileLog);
         @unlink($fileLog);
      } 
      $fileLog = OVF_FS_LOG_DIR."/lastwarning";
      if (file_exists($fileLog)) {
      	$sHTML .= "*** WARNING/NOTICE ***\r\n".file_get_contents($fileLog);
         @unlink($fileLog);
      } 
      $fileLog = OVF_FS_LOG_DIR."/lastdebug";
      if (file_exists($fileLog)) {
      	$sHTML .= "*** DEBUG ***\r\n".file_get_contents($fileLog);
         @unlink($fileLog);
      } 
      $sHTML .= "\r\n";
      if (OVF_DBG_DISPLAY_GET) {
         if (empty($_GET)) {
            $sHTML .=  "<b>GET</b> (vuoto)\r\n";
         } else {
            $sHTML .=  "<b>GET</b> ";
            $sHTML .=  print_r($_GET,1);
         }	
      	$sHTML .= "\r\n";
      }
      if (OVF_DBG_DISPLAY_POST) {
         if (empty($_POST)) {
            $sHTML .=  "<b>POST</b> (vuoto)\r\n";
         } else {
            $sHTML .=  "<b>POST</b>\n";
            $sHTML .=  print_r($_POST,1);
         }
      	$sHTML .= "\r\n";
      }
      if (OVF_DBG_DISPLAY_USER and !OVF_DBG_DISPLAY_SESS and is_object($objSess)) {
         $sHTML .=  "<b>OGGETTO UTENTE</b>\n";
         $sHTML .=  print_r($objSess,1);
      	$sHTML .= "\r\n";
      }
      if (OVF_DBG_DISPLAY_SESS) {
         $sHTML .=  "<b>SESSIONE</b>\n ";
         $sHTML .=  print_r($_SESSION,1);
      	$sHTML .= "\r\n";
      }
      $sHTML .=  "</pre>\r\n";
   }
	$sHTML .= "</body>\n</html>\n";
	return $sHTML;
}

function codaHtml() {
	echo getCodaHtml();
}

function getTestaPopUpHtml($tit1,$msgPag="",$aOpt=array()) {
	global $objSess, $objDB, $isReloadable, $isPopUp, $sXSNQS ;
	$coloreSfondo = OVF_COLORE_SFONDO;
	$coloreTesto = OVF_COLORE_TESTO;
	$nX = hexdec(substr($coloreTesto,0,2))+hexdec(substr($coloreTesto,2,2))+hexdec(substr($coloreTesto,4,2));
	$fontFamily=($nX<512)?"arial":"arialbd";
	$width = (isset($aOpt['width'])) ? $aOpt['width'] : "800";
	$sHtml = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
	$sHtml .= "<html>\n";
	$sHtml .= "<head>\n";
	$sHtml .= "<meta Name='expires' CONTENT='Mon, 1 Jan 2000 00:00:00 GMT'>\n";
	$sHtml .= "<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>\n";
	$sHtml .= "<meta HTTP-EQUIV='Cache-Control' CONTENT='no-cache'>\n";
	$sHtml .= "<meta HTTP-EQUIV='content-language' content='it'>\n";
	$sHtml .= "<meta HTTP-EQUIV='Content-Type' content='text/html; charset=iso-8859-1'>\n";
	$sHtml .= "<link rel='shortcut icon' href='".OVF_URL_ROOT."/app/_img/ovf.ico' type='image/x-icon' />\n";
	$sHtml .= "<link rel='stylesheet' href='".OVF_URL_ROOT
		."/app/_com/css.stilePar.php?cs=$coloreSfondo&ct=$coloreTesto' type='text/css'>\n";
	$sHtml .= "<title>$tit1</title>\n";
	$sHtml .= "</head>\n";
	$sHtml .= "<body onload='window.focus();' style='text-align:center;'>\n";
	$sHtml .= "<div style='width:$width;text-align:center;'>\n";
	$sHtml .= "<div align='left' style='padding:2px;background-color:#FFFFFF;border-bottom:black 1px solid;'>";
	$sHtml .= getHtmlImgLogo(array("attrImg"=>"height='30'"));
	$sHtml .= "&nbsp;&nbsp;";
	$sHtml .= getHtmlImgGen($tit1, 300, 22, 'FFFFFF', '000000', 16, $fontFamily)."\n";
	$sHtml .= "</div>\n";
	$sHtml .= "<div class='err1' align='center'>$msgPag&nbsp;</div>\n";
	return $sHtml;
}

function getCodaPopUpHtml() {
	$sHtml = "</div>\n";
	$sHtml = "</body></html>\n";
	return $sHtml;
}
